<?php

use think\migration\Migrator;
use think\migration\db\Column;

class DealerGoodsCate extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('dealer_goods_cate',  ['comment' => '经销商商品分类表']);
        $table->addColumn('dealer_id', 'integer', ['comment' => '经销商id', 'limit' => 10, 'default' => 0])
            ->addColumn('company_id', 'integer', ['comment' => '公司id', 'limit' => 10, 'default' => 0])
            ->addColumn('cate_id', 'integer', ['comment' => '分类id', 'limit' => 10, 'default' => 0])
            ->addColumn('name', 'string', ['limit' => 255, 'default' => '', 'comment' => '分类名称'])
            ->addColumn('icon', 'string', ['limit' => 255, 'default' => '', 'comment' => '分类图标'])
            ->addColumn('pid', 'integer', ['limit' => 10, 'default' => 0, 'comment' => '上级分类'])
            ->addColumn('sort', 'integer', ['limit' => 10, 'default' => 0, 'comment' => '排序'])
            ->addColumn('status', 'integer', ['limit' => 10, 'default' => 1, 'comment' => '状态：1启用 2禁用'])
            ->addColumn('remark', 'string', ['limit' => 255, 'default' => '', 'comment' => '备注'])
            ->addColumn('create_time', 'integer', ['limit' => 10, 'default' => null, 'comment' => '创建时间'])
            ->addColumn('update_time', 'integer', ['limit' => 10, 'default' => null, 'comment' => '更新时间'])
            ->addColumn('delete_time', 'integer', ['limit' => 10, 'default' => null, 'comment' => '删除时间'])
            ->addIndex('dealer_id', ['name' => 'idx_dealer_id'])
            ->addIndex('company_id', ['name' => 'idx_company_id'])
            ->addIndex('cate_id', ['name' => 'idx_cate_id'])
            ->create();

    }
}
